package com.leemz.basicui.slice;

import com.leemz.basicui.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;
import ohos.agp.components.Component;

public class ButtonSlice extends AbilitySlice {

    //跳转到拨号盘界面的按钮
    private Button dial;

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_button_layout);
        dial = (Button) findComponentById(ResourceTable.Id_dial);
        //为按钮添加点击事件
        dial.setClickedListener(new dialButtonListener());
    }

    /**
     * 按钮点击的监听
     */
    class dialButtonListener implements Component.ClickedListener {
        @Override
        public void onClick(Component component) {
            //跳转到同一个Page的另一个slice
            present(new DialSlice(), new Intent());
        }
    }
}
